package org.bim.view.drag.design.model;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.List;

/**
 * `* 描述：查询条件基础类
 * Created by bim-view on 2020/4/7.
 */
@Getter
@Setter
@ToString
@ApiModel(value = "condition",description = "查询条件基础对象")
public class BaseCondition<T> {
    @ApiModelProperty("当前页,默认1")
    private int pageNum = 1;

    @ApiModelProperty("当前页大小,默认10")
    private int pageSize = 10;

    public Page<T> transPage(List<T> list, Long total){
        Page<T> page = new Page<>();
        page.setPageSize(this.pageSize);
        page.setPageNum(this.pageNum);
        page.setList(list);
        page.setTotal(total);
        page.setPageTotal(total == 0 ? 0 : ((Double)Math.ceil(total/list.size())).intValue());
        return page;
    }
}
